<%--
  Created by IntelliJ IDEA.
  User: Admin
  Date: 2022-11-18
  Time: 15:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>生产派工单审核表</title>
    <style>
        input {
            border: white;
        }
    </style>
</head>
<form>
    <input type="hidden" name="productid" value="${param.productid}">
</form>
<form id="scdbdan2form">
    <input type="hidden" name="id" value="${param.id}">
    <input type="hidden" id="checktagswpg" name="checkTag">
    <input type="hidden"  name="manufactureProcedureTag" value="S002-0">
    <table align=center class="TABLE_STYLE6" style="margin-left:427px">
        <tr height=20 class="TR_STYLE1">
            <td class="TD_HANDBOOK_STYLE1">您正在做的业务是：生产管理--生产调度管理--制定生产派工单</td>
        </tr>
    </table>
    <table align=center class="TABLE_STYLE6" style="margin-left:1061px">
        <tr height=20 class="TR_STYLE1">
            <td>
            <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right class="TD_STYLE8">
                <input type="radio" value="0" checked="checked" name="tongg">未通过
                <input type="radio" value="1" name="tongg">通过
                <input type="button" value="确定" class="btn btn-success" id="scdbdan2formbtn">&nbsp;
            </td>
        </tr>
    </table>

    <input name="design_ID" type="hidden">
    <input name="product_ID" type="hidden">
    <div class="DIV_STYLE2">
        <table cellspacing=0 cellpadding=0 width=350 align=center border=0 bgcolor="#FFFFFF">
            <tbody>
            <tr>
                <td valign=bottom align=center class="TABLE_STYLE6" rowspan=2>
                    <table cellspacing=0 cellpadding=0 width="800px" border=0
                           style="BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; BORDER-LEFT: #333333 1px solid; BORDER-BOTTOM: #333333 1px solid;">
                        <tbody>
                        <tr>
                            <td colspan="4" height="10">
                                <table width="850px" style="height: 400px">
                                    <tr>
                                        <td>
                                            <table align=center class="TABLE_STYLE4">
                                                <tr height=20 class="TR_STYLE1">
                                                    <td align=center height=5 class="TD_STYLE5">&nbsp;</td>
                                                </tr>
                                            </table>
                                            <table align=center class="TABLE_STYLE4">
                                                <tr height=20 class="TR_STYLE1">
                                                    <td align=center height=5 class="TD_STYLE5"><font size="4"><b>生产派工单</b></font>
                                                    </td>
                                                </tr>
                                            </table>
                                            <table align=center class="TABLE_STYLE4">
                                                <tr height=20 class="TR_STYLE1">
                                                    <td align=center height=5 class="TD_STYLE5">&nbsp;</td>
                                                </tr>
                                            </table>
                                            <table align=center class="TABLE_STYLE4">
                                                <tr height=20 class="TR_STYLE1">
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="14%">派工单编号：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" name="manufactureId" id="manufactureId3" readonly  > &nbsp;
                                                    </td>
                                                </tr>
                                                <tr height=20 class="TR_STYLE1">
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="10%">产品名称：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" name="productName" id="productName3" readonly>&nbsp;
                                                    </td>
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="13%">产品编号&nbsp;&nbsp;：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" name="productId" id="productId3" readonly>&nbsp;
                                                    </td>
                                                </tr>
                                                <tr height=20 >
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="10%">数量&nbsp;&nbsp;：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" name="amount" id="amount3" readonly>&nbsp;
                                                    </td>
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="14%">工单制定人&nbsp;&nbsp;：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" name="designer" id="designer3" >&nbsp;
                                                    </td>
                                                </tr>

                                            </table>

                                            <table id="pgddshtable" align=center
                                                   class="table table-striped table-bordered table-condensed table-hover">
                                            </table>
                                            <table align=center class="TABLE_STYLE4">
                                                <tr height=20 class="TR_STYLE1">
                                                </tr>
                                            </table>
                                            <TABLE align=center class="TABLE_STYLE4">
                                                <tr height=20 class="TR_STYLE1">
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="17%">工时总成本&nbsp;&nbsp;：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" name="labourCostPriceSum"  id="labourCostPriceSum3">&nbsp;
                                                    </td>
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="14%">物料总成本：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" id="realModuleCostPriceSum3" readonly
                                                               name="realModuleCostPriceSum">&nbsp;
                                                    </td>
                                                </tr>
                                                <tr height=20 class="TR_STYLE1">
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="12%">登记人&nbsp;&nbsp;：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" name="register" value="${username}" id="register3">&nbsp;
                                                    </td>
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="10%">登记时间：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" id="registerTime3" readonly
                                                               name="registerTime">&nbsp;
                                                    </td>
                                                </tr>
                                                <tr height=20 class="TR_STYLE1">
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="10%">审核人&nbsp;&nbsp;：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" name="checker" value="${username}" id="checker3">&nbsp;
                                                    </td>
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="10%">审核时间：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" id="checkTime3" readonly
                                                               name="checkTime">&nbsp;
                                                    </td>
                                                </tr>
                                                <tr height=20 class="TR_STYLE1">
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="10%">描述&nbsp;&nbsp;：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" name="productDescribe" readonly id="productDescribe3">&nbsp;
                                                    </td>
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="10%"> 出库单编号：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="40%">
                                                        <input type="text" id="chukudaniddan2" readonly
                                                               name="registertime">&nbsp;
                                                    </td>
                                                </tr>
                                                <tr height=20 class="TR_STYLE1">
                                                    <td bordercolorlight=#848284 bordercolordark=#eeeeee align=right
                                                        class="TD_STYLE8" width="10%">备注：
                                                    </td>
                                                    <td bordercolor=#DEDBD6 align=left class="TD_STYLE2" width="89%"
                                                        colspan="3"><textarea name="remark"
                                                                              id="remarkdan2table" style="width: 561px; height: 171px;"></textarea>&nbsp;
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" nowrap width="56">
                            </td>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" nowrap height="100"></td>
                            <td></td>
                        </tr>

                        <tr valign="bottom">
                            <td colspan="4" nowrap align="center"></td>
                        </tr>
                        </td>
                        <tr>
                            <td colspan="4" nowrap align="right"></td>
                        </tr>
                        </tbody>
                    </table>
                </td>
                <td width=1 bgcolor=#ffffff height=2></td>
                <td width=1 bgcolor=#ffffff height=2></td>
                <td width=1 bgcolor=#ffffff height=2></td>
            </tr>
            <tr>
                <td width=1 bgcolor=#333333 height=120></td>
                <td width=1 bgcolor=#666666 height=120></td>
                <td width=1 bgcolor=#999999 height=120></td>
            </tr>
            <tr valign=top align=right>
                <td colspan=4>
                    <table cellspacing=0 cellpadding=0 align=center class="TABLE_STYLE6" border=0>
                        <tbody>
                        <tr>
                            <td bgcolor=#333333 height=1></td>
                        </tr>
                        <tr>
                            <td bgcolor=#666666 height=1></td>
                        </tr>
                        <tr>
                            <td bgcolor=#999999 height=1></td>
                        </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
            <tr valign=center align=right>
                <td colspan=4></td>
            </tr>
            </tbody>
        </table>
    </div>
</form>

<!--外层容器div-->
<div class="modal " id="dqshaddwintablepg" data-backdrop="static">
    <!--对话框容器div-->
    <div class="modal-dialog modal-lg">
        <!--对话框内容容器div-->
        <div class="modal-content">

        </div>
    </div>
</div>

<script>
    $(function () {
        // 获取当前时间
        var time = getTime();
        $("#checkTime3").val(time)
        var designid = '${param.id}'
        $.get("queryMManufacture2.action/" + designid, function (data) {
            $("#manufactureId3").val(data.manufactureId)
            $("#productId3").val(data.productId)
            $("#productName3").val(data.productName)
            $("#amount3").val(data.amount)
            $("#productDescribe3").val(data.productDescribe)
            $("#moduleCostPriceSum3").val(data.moduleCostPriceSum)
            $("#labourCostPriceSum3").val(data.labourCostPriceSum)
            $("#remarkdan2table").val(data.remark)
            $("#designer3").val(data.designer)
            $("#register3").val(data.register)
            $("#registerTime3").val(data.registerTime)
            $("#checker3").val(data.checker)
            var productId=data.productId
            $("#pgddshtable").bootstrapTable({
                url: "querydDesignProcedureDetailscpid22Id.action",
                method: 'post',                      //请求方式（*）
                contentType: "application/x-www-form-urlencoded",
                // toolbar: '#toolbar',              //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                   //是否显示分页（*）
                sortable: true,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                      //初始化加载第一页，默认第一页,并记录
                pageSize: 5,                     //每页的记录行数（*）
                pageList: [5, 10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                      //是否显示表格搜索
                strictSearch: true,
                showColumns: true,                  //是否显示所有的列（选择显示的列）
                showRefresh: true,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
                height: 500,                      //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                uniqueId: "id",                     //每一行的唯一标识，一般为主键列
                showToggle: true,                   //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,                  //是否显示父子表
                //得到查询的参数
                queryParams: function (params) {
                    //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                    var temp = {
                        pagesize: params.limit,                         //页面大小
                        pagenum: (params.offset / params.limit) + 1,   //页码
                        sort: params.sort,      //排序列名
                        sortOrder: params.order, //排位命令（desc，asc）
                        productId:productId
                        };
                    return temp;
                },
                //产品生产工序明细
                columns: [
                    {
                        field: 'id',
                        title: '序号'
                    }
,
                    {
                        field: 'procedurename',
                        title: '工序名称'
                    }

                    , {
                        field: 'procedureid',
                        title: '工序编号'
                    }, {
                        field: 'proceduredescribe',
                        title: '描述'
                    }
                    , {
                        field: 'labourhouramount',
                        title: '工时数(小时)',
                        formatter: function (value, row, index) {
                            return "<input type='text' value='" + value + "' onchange='changenum112(this)' >";
                        }

                    },
                    {
                        field: 'amountunit',
                        title: '工时成本小计(元)',
                        formatter: function (value, row, index) {
                            if (value == "" || value == null) {
                                return "<label class='label leabel-success'>小时</label>";
                            }

                        }
                    },
                    {
                        field: 'costprice',
                        title: '物料成本小计',
                        formatter: function (value, row, index) {
                            return "<input type='text' value='" + value + "' onchange='changenum222(this)' >";
                        }

                    },
                    {
                        field: 'subtotal',
                        title: '审核物料',
                        formatter: function (value, row, index) {
                            return "<a href='#' onclick='scdbdanshbtn(" + row.id + ")' class='btn btn-success'>审核物料</a>";
                        }
                        //产品生产工序物料明细parentid  M_DESIGN_PROCEDURE_DETAILS
                    }]
            });

        }, "json")

    })

    function scdbdanshbtn(parentid) {
        $("#dqshaddwintablepg").modal({
            remote: "dplistzdsjquery2.jsp?parentid="+ parentid
        });
    }


    //保存
    $("#scdbdan2formbtn").click(function () {
        //  通過
        if ($(":radio:checked").val() == 1) {
            //CHECK_TAG
            $("#checktagswpg").val("S001-1")
            //確定
            var dataobj = $("#scdbdan2form").serializeArray();
            var obj = {};
            $(dataobj).each(function (index, item) {
                obj[item.name] = item.value;
            })
            $.ajax({
                url: "udpateMManufacture.action",
                type: "put",
                data: JSON.stringify(obj),
                contentType: "application/json",
                dataType: "json",
                success: function (data) {
                    alert(data.msg)
                }
            })
        }
        else if($(":radio:checked").val() == 0){
            $("#checktagswpg").val("S001-3")

            var dataobj = $("#scdbdan2form").serializeArray();
            var obj = {};
            $(dataobj).each(function (index, item) {
                obj[item.name] = item.value;
            })
            $.ajax({
                url: "udpateMManufacture.action",
                type: "put",
                data: JSON.stringify(obj),
                contentType: "application/json",
                dataType: "json",
                success: function (data) {
                    if(data.cm==1) {
                        var dataobj = $("#filebyidpcpg").serializeArray();
                        var obj = {};
                        $(dataobj).each(function (index, item) {
                            obj[item.name] = item.value;
                        })
                        $.ajax({
                            url: "udpateapplypg.action",
                            type: "put",
                            data: JSON.stringify(obj),
                            contentType: "application/json",
                            dataType: "json",
                            success: function (data) {
                            }
                        })
                    }
                }
            })
            $("#checktagswpg").val("S001-2")
            var dataobj2 = $("#scdbdan2form").serializeArray();
            var obj2 = {};
            $(dataobj2).each(function (index, item) {
                obj2[item.name] = item.value;
            })
            $.ajax({
                url: "readdmManufacture.action",
                type: "put",
                data: JSON.stringify(obj2),
                contentType: "application/json",
                dataType: "json",
                success: function (data) {
                    alert(data.msg)
                }
            })
        }
    })


    // 获取当前日期时间方法
    function getTime() {
        var date = new Date();
        var y = date.getFullYear();
        var M = date.getMonth() + 1;
        M = M < 10 ? ('0' + M) : M;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d
        var h = date.getHours();
        var m = date.getMinutes();
        var s = date.getSeconds();
        const time = y + '-' + M + '-' + d + " " + h + ":" + m + ":" + s;
        return time;
    }

</script>
</body>
</html>
